<?php
/**
 * @author qingyu8@staff.weibo.com
 * @date 2018/04/22
 */
namespace common\logic;

use common\models\Tour as TourModel;

class Tour {

    public static function getBoatTours($boatId, $startMonth) {

        if (empty($boatId) || empty($startMonth)) {
            return [
                'err' => 1,
                '参数错误'
            ];
        }
        $ids = Trip::getTourIds($boatId, $startMonth);
        if(empty($ids)) return [];
        $idsStr = implode(',', $ids);
        return TourModel::getList("id IN ($idsStr)");
    }
    public static function getTours($tourIds = []){
        if(empty($tourIds)) return [];
        $idsStr = implode(',', $tourIds);
        return TourModel::getList("id IN ($idsStr)");
    }
    public static function getTourInfoByBoat($boatId){
        $sql="SELECT b.* FROM `dive_trip` as a
JOIN dive_tour as b on a.tour_id=b.id
where a.boat_id=$boatId LIMIT $boatId";
        $r=TourModel::getDb()->createCommand($sql)->queryOne();
        return $r;
    }
}
